<?php
namespace app\common\model\shop;

use app\common\model\shop\ozon\OzonGoodsAttributeModel;
use app\common\model\shop\ozon\OzonGoodsImageModel;
use app\common\model\shop\ozon\OzonGoodsModel;
use app\common\model\shop\ozon\OzonGoodsSkuModel;
use app\common\model\shop\self\SelfGoodsAttributeModel;
use app\common\model\shop\self\SelfGoodsImageModel;
use app\common\model\shop\self\SelfGoodsModel;
use app\common\model\shop\self\SelfGoodsSkuModel;
use think\admin\Model;

/**
 * 公共GoodsModel
 * 公共商品
 * @Description
 * @package app\common\model\shop
 * @author xuli
 * @date 2024-11-02 14:17
 */
class GoodsModel extends Model
{

    public static function instance($platform_id)
    {
        $model = $sku_model = $attr_model = $image_model = null;
        $platform_info = PlatformModel::mk()->find($platform_id);
        if (empty($platform_info)) {
            return [$model, $sku_model, $attr_model, $image_model];
        }
        // 根据平台实例化相应模型
        switch ($platform_info['code']) {
            case PlatformModel::OZON_CODE:
                $model = new OzonGoodsModel();
                $sku_model = new OzonGoodsSkuModel();
                $attr_model = new OzonGoodsAttributeModel();
                $image_model = new OzonGoodsImageModel();
                break;
            case PlatformModel::SELF_CODE:
                $model = new SelfGoodsModel();
                $sku_model = new SelfGoodsSkuModel();
                $attr_model = new SelfGoodsAttributeModel();
                $image_model = new SelfGoodsImageModel();
                break;
        }
        return [$model, $sku_model, $attr_model, $image_model];
    }

    /**
     * 获取需要翻译的内容模块
     *
     * @Description
     * @author wangqinghui
     * @date 2024-11-05 16:53
     * @return array
     */
    public static function getTranslatePart() : array
    {
        return [
            'common'    => [
                'is_title'   => lang('标题'),
                'is_short_desc' => lang('短描述'),
                'is_long_desc'    => lang('长描述'),
            ],
            'extra'     => [
                'is_sku'    => lang('翻译SKU规格'),
            ],
        ];
    }

    /**
     * 翻译API映射
     *
     * @Description
     * @author wangqinghui
     * @date 2024-11-08 14:10
     * @return array
     */
    public static function getTranslateApiArr() : array
    {
        return ['baidu_translate' => 'BaiduFaiyi'];
    }
}